﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:s="http://www.codeplex.com/MSSqlSchemaDoc">

  <xsl:import href="Column.xsl"/>
  <xsl:param name="DocumentationFile"/>

  <xsl:template match="s:Triggers">

    <tr>
      <td colspan="2" class="descriptionHeader center">
        Triggers:
      </td>
    </tr>

    <tr>
      <td colspan="2">
        <table width="100%">
          <tr class="center tableHeader">
            <td></td>
            <td>Events</td>
            <td>Is Instead Of</td>
          </tr>

          <xsl:for-each select="s:Trigger">
            <xsl:variable name="TriggerName" select="@Name"/>
            <xsl:variable name="TriggerSchema" select="@Schema"/>

            <tr class="center">
              <td class="tablePrimaryColumn">
                <xsl:value-of select="@Schema"/>.<xsl:value-of select="@Name"/>
              </td>
              <td>
                <xsl:for-each select="s:Events/s:TriggerEvent">
                  <xsl:value-of select="@Name"/>
                  <br />
                </xsl:for-each>
              </td>
              <td>
                <xsl:value-of select="s:IsInsteadOf"/>
              </td>
            </tr>
            <tr>
              <td colspan="3" class="documentation center">
                <pre>
                  <xsl:value-of select="document($DocumentationFile)/s:TableDocumentation/s:Triggers/s:TableTriggerDocumentation[@Name=$TriggerName][@Schema=$TriggerSchema]/s:Documentation"/>
                </pre>
              </td>
            </tr>
          </xsl:for-each>

        </table>
      </td>
    </tr>


  </xsl:template>

</xsl:stylesheet>